package bravo.xc.com.xc_bravo_android.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import org.w3c.dom.Text;

import java.util.List;

import bravo.xc.com.xc_bravo_android.R;
import bravo.xc.com.xc_bravo_android.beans.GetCardResultBeans;
import bravo.xc.com.xc_bravo_android.beans.WithdrawRecordResultBeans;

/**
 * CREATED BY YANK
 * DATE : 2017/11/8
 * MAIL : YANK.TENYOND@GMAIL.COM
 * FUNCTION :
 */

public class WithDrawAdapter extends BaseAdapter{

    private Context mContext;
    private int resourceId;
    private List<WithdrawRecordResultBeans.DataBean> dataBeans;

    public WithDrawAdapter(Context context , int textViewResourceId, List<WithdrawRecordResultBeans.DataBean> objects) {
        super();
        this.mContext=context;
        this.resourceId=textViewResourceId;
        this.dataBeans =objects;
        //initData();
    }

    @Override
    public int getCount() {
        return dataBeans.size();
    }

    @Override
    public WithdrawRecordResultBeans.DataBean getItem(int position) {
        return dataBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        WithDrawAdapter.Holder holder=new WithDrawAdapter.Holder();
        if(convertView==null){
            convertView= LayoutInflater.from(mContext).inflate(R.layout.item_withdraw_record,null);
            holder.recordCard= (TextView)convertView.findViewById(R.id.tv_withdraw_bankcardnum);
            holder.recordTime= (TextView) convertView.findViewById(R.id.tv_withdraw_time);
            holder.recordNum= (TextView) convertView.findViewById(R.id.tv_withdraw_moneys);
            holder.recordStatus= (TextView) convertView.findViewById(R.id.tv_withdraw_state);
            convertView.setTag(holder);
        }else{
            holder=(WithDrawAdapter.Holder)convertView.getTag();
        }
        holder.recordTime.setText(dataBeans.get(position).getCreateTime());
        holder.recordNum.setText(String.valueOf(dataBeans.get(position).getSum())+"元");
        holder.recordCard.setText(dataBeans.get(position).getBankNum());
        switch (dataBeans.get(position).getStatus()){
            case 0:
                holder.recordStatus.setText("已拒绝");
                break;
            case 1:
                holder.recordStatus.setText("未审核");
                break;
            case 2:
                holder.recordStatus.setText("打款中");
                break;
            case 3:
                holder.recordStatus.setText("完成");

        }
        //根据isSelected来设置item的选中情况
        notifyDataSetChanged();
        return convertView;
    }
    class Holder{
        TextView recordTime;
        TextView recordNum;
        TextView recordCard;
        TextView recordStatus;
    }
}
